feat(tool): print message receipt size and event size in forest-tool archive info#6821
Conversation
WalkthroughThe changes add size metrics tracking for receipts and events in archive information. A new public method for computing blockstore byte size is added to MemoryDB, and archive command logic is enhanced with fields and read-operation tracking to measure and display these sizes. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/db/memory.rs (1)
27-34: Add rustdoc for the new public method.
blockstore_size_bytesis a public API and should have a short doc comment describing what bytes are included (CID bytes + block bytes, both maps).As per coding guidelines: "Document public functions and structs with doc comments".Suggested patch
impl MemoryDB { + /// Returns the total byte size of blocks stored in memory, including + /// both CID key bytes and block payload bytes across ephemeral and + /// persistent block maps. pub fn blockstore_size_bytes(&self) -> usize { self.blockchain_db .read() .iter() .chain(self.blockchain_persistent_db.read().iter()) .map(|(k, v)| k.to_bytes().len() + v.len()) .sum() }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/db/memory.rs` around lines 27 - 34, Add a Rust doc comment to the public method blockstore_size_bytes describing what it returns and what bytes are counted: state that it returns the total size in bytes of both in-memory maps (blockchain_db and blockchain_persistent_db), summing each entry's CID key bytes (k.to_bytes().len()) plus the block value bytes (v.len()), and clarify that both maps are included. Place the doc comment immediately above the pub fn blockstore_size_bytes(&self) signature.src/tool/subcommands/archive_cmd.rs (1)
315-317: Add a regression test for the new size fields inArchiveInfooutput.Since CLI text now includes
Receipts sizeandEvents size, a focused test asserting these lines exist (and remain formatted) would make this safer against future refactors.Also applies to: 331-342
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tool/subcommands/archive_cmd.rs` around lines 315 - 317, Add a regression test that verifies the CLI text output for ArchiveInfo includes the new size lines: assert the output contains properly formatted "Receipts size" and "Events size" lines tied to the ArchiveInfo fields message_receipts_size and events_size; locate where ArchiveInfo is rendered (the Display impl or the function that formats archive output used by the archive subcommand) and write a test that constructs an ArchiveInfo with known message_receipts_size/events_size (and counts) and asserts the generated string contains the exact labeled lines (e.g., "Receipts size:" and "Events size:") so future refactors won't remove or reformat them.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/db/memory.rs`:
- Around line 27-34: Add a Rust doc comment to the public method
blockstore_size_bytes describing what it returns and what bytes are counted:
state that it returns the total size in bytes of both in-memory maps
(blockchain_db and blockchain_persistent_db), summing each entry's CID key bytes
(k.to_bytes().len()) plus the block value bytes (v.len()), and clarify that both
maps are included. Place the doc comment immediately above the pub fn
blockstore_size_bytes(&self) signature.
In `@src/tool/subcommands/archive_cmd.rs`:
- Around line 315-317: Add a regression test that verifies the CLI text output
for ArchiveInfo includes the new size lines: assert the output contains properly
formatted "Receipts size" and "Events size" lines tied to the ArchiveInfo fields
message_receipts_size and events_size; locate where ArchiveInfo is rendered (the
Display impl or the function that formats archive output used by the archive
subcommand) and write a test that constructs an ArchiveInfo with known
message_receipts_size/events_size (and counts) and asserts the generated string
contains the exact labeled lines (e.g., "Receipts size:" and "Events size:") so
future refactors won't remove or reformat them.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8c65b8cd-0415-40f8-b1c4-23e63b0dc570
📒 Files selected for processing (3)
CHANGELOG.mdsrc/db/memory.rssrc/tool/subcommands/archive_cmd.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 9 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
forest-tool archive infocommand now reports message receipt size and event size metrics in addition to existing output.